export function useToast(duration = 1500) {
  const success = (text: string) => {
    uni.showToast({
      type: 'success',
      title: text,
      icon: 'success',
      duration,
      mask: true,
    });
  };
  const error = (text: string) => {
    uni.showToast({
      type: 'error',
      title: text,
      icon: 'error',
      duration,
      mask: true,
    });
  };
  const info = (text: string) => {
    uni.showToast({
      title: text,
      icon: 'none',
      duration,
      mask: true,
    });
  };

  const loading = (text: string = '加载中') => {
    uni.showLoading({
      title: text,
      mask: true,
    });
  };

  const hideLoading = () => {
    uni.hideLoading()
  };

  return {
    loading,
    hideLoading,
    success,
    error,
    info,
    show: uni.showToast,
  };
}
